Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Split by lines when parsing stdout of build #1276

Closed
wants to merge 3 commits into from

Conversation

clouds56
Copy link

Fixes #1275

@@ -725,9 +725,14 @@ export class ArduinoApp {
}
return ret;
}
let stdoutbuf = ""
const stdoutcb = (line: string) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name line is obviously misleading since it really is chunks of stdout text, not specifically split into lines, so this name should be updated as well.

I suggest stdoutText which is descriptive and also matches the documentation to the spawn function in src/common/util.ts (which is missing an update to match its current parameters, great if you could fix that as well).

With a rename of the function argument in stdoutcb (and fix stderrcb as well at the same time), then you could use stdoutText directly without needing to copy to a stdoutbuf variable.

let lines = [stdoutbuf];
lines = stdoutbuf.split('\n');
stdoutbuf += line;
let lines = stdoutbuf.split('\n');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const lines = ...

let lines = [stdoutbuf];
lines = stdoutbuf.split('\n');
stdoutbuf += line;
let lines = stdoutbuf.split('\n');
stdoutbuf = lines.pop()!;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This statement can be removed, there is no point in updating stdoutbuf after its last usage.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stdoutbuf is upvalue variable of the closure, the last update is taking the remain characters that in last line.

@benmcmorran benmcmorran changed the base branch from release to main January 13, 2022 22:35
@clouds56
Copy link
Author

close as #1494 merged

@clouds56 clouds56 closed this Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parse failed when cmdline too long
3 participants